# -*- coding: utf-8 -*-
# !/usr/bin/env python
import uuid

from components.models import KubernetesManage, HostsManagement
from utils.views import ReturnClass


def save_kubernete_node_info(host_id, kubernetes_manage_id, kubernetes_role, host_nick):
    HostsManagement.objects.filter(host_id=host_id).update(host_nick=host_nick)

    kubernetes_manage_obj = KubernetesManage.objects.filter(kubernetes_manage_id=kubernetes_manage_id)

    for kubernetes_manage_obj_one in kubernetes_manage_obj:
        if not kubernetes_manage_obj_one.deploy_event_ids:
            kubernetes_manage_obj.update(deploy_event_ids=str(uuid.uuid1()))

    kubernetes_manage_obj.update(kubernetes_role=kubernetes_role)

    return ReturnClass.return_succeed("查询成功")